package com.fabriciojf.model;

import java.io.Serializable;
import java.util.List;
import java.util.Vector;
import javax.persistence.*;

/**
 * Entidade
 *
 * @author Fabricio S Costa fabriciojf@gmail.com
 * @since 01/12/2009
 * @version 1.0
 */
@Entity
@Table(name="usuario")
public class Usuario implements Serializable {

    @Id
    private String js_user;
    private String js_password;

    @ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(joinColumns=@JoinColumn(name="js_user"),
    inverseJoinColumns=@JoinColumn(name="rolename"))
    private List<Js_Role> js_roles;

    /** Creates a new instance of Usuario */
    public Usuario() {
    }

    public Usuario(String js_user, String js_password, Js_Role js_role) {
        super();
        this.js_user = js_user;
        this.js_password = js_password;
        getJs_Roles().add(js_role);
    }

    public List<Js_Role> getJs_Roles() {
        if (js_roles == null) {
            js_roles = new Vector<Js_Role>();
        }
        return js_roles;
    }

    public String getJs_user() {
        return js_user;
    }

    public void setJs_user(String js_user) {
        this.js_user = js_user;
    }

    public String getJs_password() {
        return js_password;
    }

    public void setJs_password(String js_password) {
        this.js_password = js_password;
    }
}
